<template>
  <div class="reply-wrap">
    <el-form :model="form">
      <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入回复内容"
        v-model="form.content"
      >
      </el-input>
      <div class="reply-btn">
        <el-button
          size="mini"
          type="custom"
          :disabled="form.content.length == 0"
          v-preventReClick
          @click="submitForm"
          >发表</el-button
        >
      </div>
    </el-form>
    <div style="clear: both"></div>
  </div>
</template>
<script>
import { sysEvaluateAdd } from '@/api/home/sysEvaluate.js'
import Bus from '@/utils/bus.js'
export default {
  data() {
    return {
      form: {
        pid: '', //父级节点(评价类型不传)
        resId: '', //资源ID
        content: '',
        score: 0, //评分
        type: '2', //节点类型；1-评价，2-回复
        resType: '2', //资源类型；1-课程，2-知识点，3-…
      },
    }
  },
  props: ['replyData'],
  mounted() {
    let { id, resId, resType } = this.replyData
    this.form.pid = id
    this.form.resId = resId
    this.form.resType = resType
  },
  methods: {
    submitForm() {
      sysEvaluateAdd(this.form).then((res) => {
        this.$parent.replyIdx = -1
        Bus.$emit('refreshReviewList')
        this.$message({
          message: '操作成功',
          type: 'success',
        })
      })
    },
  },
}
</script>
<style scoped lang="scss">
.reply-wrap {
  margin-top: 10px;
  .reply-btn {
    margin-top: 10px;
    float: right;
  }
}
</style>